package com.example.demo810.event;

import com.example.demo810.repo.UserRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author lzh
 * @date 2020/8/11 - 18:25
 */
@Component
public class ListenerTest1 implements ApplicationListener<EventTest> {

    @Autowired
    UserRepo userRepo;



    @Override
    public void onApplicationEvent(EventTest eventTest) {
        System.out.println("已监听到事件/信号"+new Date().toString());

        System.out.println("执行监听器 监听后的执行方法");
        System.out.println( userRepo.findAll().toString());

    }
}
